#include <dbg.h>
#include <gtest/gtest.h>
using std::vector;

class Solution {
public:
    static int removeElement(vector<int>& nums, int val) {
        const size_t n = nums.size();

        size_t slowIndex = 0;
        for (size_t fastIndex = 0; fastIndex < n; ++fastIndex) {
            if (val != nums[fastIndex]) {
                nums[slowIndex++] = nums[fastIndex];
            }
        }
        return static_cast<int>(slowIndex);
    }
};

TEST(TEST1, removeElement) {
    Solution s;
    vector nums{3, 2, 2, 3};
    constexpr int val = 3;
    EXPECT_EQ(s.removeElement(nums, val), 2);
}

TEST(TEST2, removeElement) {
    Solution s;
    vector nums{0, 1, 2, 2, 3, 0, 4, 2};
    constexpr int val = 2;
    EXPECT_EQ(s.removeElement(nums, val), 5);
}

int main(int argc, char** argv) {
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}